home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / AEObjects.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  15.4 KB  |  352 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        AEObjects.h
  3.  
  4.      Contains:    AppleEvents Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __AEOBJECTS__
  21. #define __AEOBJECTS__
  22.  
  23.  
  24. #ifndef __MEMORY__
  25. #include <Memory.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <MixedMode.h>                                        */
  30.  
  31. #ifndef __OSUTILS__
  32. #include <OSUtils.h>
  33. #endif
  34.  
  35. #ifndef __QUICKDRAW__
  36. #include <Quickdraw.h>
  37. #endif
  38. /*    #include <QuickdrawText.h>                                    */
  39.  
  40. #ifndef __EVENTS__
  41. #include <Events.h>
  42. #endif
  43.  
  44. #ifndef __EPPC__
  45. #include <EPPC.h>
  46. #endif
  47. /*    #include <Errors.h>                                            */
  48. /*    #include <AppleTalk.h>                                        */
  49. /*    #include <Files.h>                                            */
  50. /*    #include <PPCToolbox.h>                                        */
  51. /*    #include <Processes.h>                                        */
  52.  
  53. #ifndef __APPLEEVENTS__
  54. #include <AppleEvents.h>
  55. #endif
  56. /*    #include <Notification.h>                                    */
  57.  
  58. #ifndef __ERRORS__
  59. #include <Errors.h>
  60. #endif
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. #if PRAGMA_ALIGN_SUPPORTED
  67. #pragma options align=mac68k
  68. #endif
  69.  
  70. #if PRAGMA_IMPORT_SUPPORTED
  71. #pragma import on
  72. #endif
  73.  
  74.  
  75. enum {
  76.     kAEAND                        = 'AND ',                        /*  0x414e4420  */
  77.     kAEOR                        = 'OR  ',                        /*  0x4f522020  */
  78.     kAENOT                        = 'NOT ',                        /*  0x4e4f5420  */
  79. /****    ABSOLUTE ORDINAL CONSTANTS    ****/
  80.     kAEFirst                    = 'firs',                        /*  0x66697273  */
  81.     kAELast                        = 'last',                        /*  0x6c617374  */
  82.     kAEMiddle                    = 'midd',                        /*  0x6d696464  */
  83.     kAEAny                        = 'any ',                        /*  0x616e7920  */
  84.     kAEAll                        = 'all ',                        /*  0x616c6c20  */
  85. /****    RELATIVE ORDINAL CONSTANTS    ****/
  86.     kAENext                        = 'next',                        /*  0x6e657874  */
  87.     kAEPrevious                    = 'prev',                        /*  0x70726576  */
  88. /****    KEYWORD CONSTANT     ****/
  89.     keyAECompOperator            = 'relo',                        /*  0x72656c6f  */
  90.     keyAELogicalTerms            = 'term',                        /*  0x7465726d  */
  91.     keyAELogicalOperator        = 'logc',                        /*  0x6c6f6763  */
  92.     keyAEObject1                = 'obj1',                        /*  0x6f626a31  */
  93.     keyAEObject2                = 'obj2',                        /*  0x6f626a32  */
  94. /*    ... for Keywords for getting fields out of object specifier records. */
  95.     keyAEDesiredClass            = 'want',                        /*  0x77616e74  */
  96.     keyAEContainer                = 'from',                        /*  0x66726f6d  */
  97.     keyAEKeyForm                = 'form',                        /*  0x666f726d  */
  98.     keyAEKeyData                = 'seld'
  99. };
  100.  
  101. enum {
  102. /*    ... for Keywords for getting fields out of Range specifier records. */
  103.     keyAERangeStart                = 'star',                        /*  0x73746172  */
  104.     keyAERangeStop                = 'stop',                        /*  0x73746f70  */
  105. /*    ... special handler selectors for OSL Callbacks. */
  106.     keyDisposeTokenProc            = 'xtok',                        /*  0x78746f6b  */
  107.     keyAECompareProc            = 'cmpr',                        /*  0x636d7072  */
  108.     keyAECountProc                = 'cont',                        /*  0x636f6e74  */
  109.     keyAEMarkTokenProc            = 'mkid',                        /*  0x6d6b6964  */
  110.     keyAEMarkProc                = 'mark',                        /*  0x6d61726b  */
  111.     keyAEAdjustMarksProc        = 'adjm',                        /*  0x61646a6d  */
  112.     keyAEGetErrDescProc            = 'indc'
  113. };
  114.  
  115. /****    VALUE and TYPE CONSTANTS    ****/
  116. enum {
  117. /*    ... possible values for the keyAEKeyForm field of an object specifier. */
  118.     formAbsolutePosition        = 'indx',                        /*  0x696e6478  */
  119.     formRelativePosition        = 'rele',                        /*  0x72656c65  */
  120.     formTest                    = 'test',                        /*  0x74657374  */
  121.     formRange                    = 'rang',                        /*  0x72616e67  */
  122.     formPropertyID                = 'prop',                        /*  0x70726f70  */
  123.     formName                    = 'name',                        /*  0x6e616d65  */
  124. /*    ... relevant types (some of these are often pared with forms above). */
  125.     typeObjectSpecifier            = 'obj ',                        /*  0x6f626a20  */
  126.     typeObjectBeingExamined        = 'exmn',                        /*  0x65786d6e  */
  127.     typeCurrentContainer        = 'ccnt',                        /*  0x63636e74  */
  128.     typeToken                    = 'toke',                        /*  0x746f6b65  */
  129.     typeRelativeDescriptor        = 'rel ',                        /*  0x72656c20  */
  130.     typeAbsoluteOrdinal            = 'abso',                        /*  0x6162736f  */
  131.     typeIndexDescriptor            = 'inde',                        /*  0x696e6465  */
  132.     typeRangeDescriptor            = 'rang',                        /*  0x72616e67  */
  133.     typeLogicalDescriptor        = 'logi',                        /*  0x6c6f6769  */
  134.     typeCompDescriptor            = 'cmpd',                        /*  0x636d7064  */
  135.     typeOSLTokenList            = 'ostl'
  136. };
  137.  
  138. /* Possible values for flags parameter to AEResolve.  They're additive */
  139. enum {
  140.     kAEIDoMinimum                = 0x0000,
  141.     kAEIDoWhose                    = 0x0001,
  142.     kAEIDoMarking                = 0x0004,
  143.     kAEPassSubDescs                = 0x0008,
  144.     kAEResolveNestedLists        = 0x0010,
  145.     kAEHandleSimpleRanges        = 0x0020,
  146.     kAEUseRelativeIterators        = 0x0040
  147. };
  148.  
  149. /**** SPECIAL CONSTANTS FOR CUSTOM WHOSE-CLAUSE RESOLUTION */
  150. enum {
  151.     typeWhoseDescriptor            = 'whos',                        /*  0x77686f73  */
  152.     formWhose                    = 'whos',                        /*  0x77686f73  */
  153.     typeWhoseRange                = 'wrng',                        /*  0x77726e67  */
  154.     keyAEWhoseRangeStart        = 'wstr',                        /*  0x77737472  */
  155.     keyAEWhoseRangeStop            = 'wstp',                        /*  0x77737470  */
  156.     keyAEIndex                    = 'kidx',                        /*  0x6b696478  */
  157.     keyAETest                    = 'ktst'
  158. };
  159.  
  160. /**
  161.     used for rewriting tokens in place of 'ccnt' descriptors
  162.     This record is only of interest to those who, when they...
  163.     ...get ranges as key data in their accessor procs, choose
  164.     ...to resolve them manually rather than call AEResolve again.
  165. **/
  166. struct ccntTokenRecord {
  167.     DescType                        tokenClass;
  168.     AEDesc                            token;
  169. };
  170. typedef struct ccntTokenRecord ccntTokenRecord, *ccntTokenRecPtr, **ccntTokenRecHandle;
  171.  
  172. typedef AEDesc *DescPtr, **DescHandle;
  173.  
  174. /* typedefs providing type checking for procedure pointers */
  175. typedef pascal OSErr (*OSLAccessorProcPtr)(DescType desiredClass, const AEDesc *container, DescType containerClass, DescType form, const AEDesc *selectionData, DescPtr value, long accessorRefcon);
  176. typedef pascal OSErr (*OSLCompareProcPtr)(DescType oper, const AEDesc *obj1, const AEDesc *obj2, Boolean *result);
  177. typedef pascal OSErr (*OSLCountProcPtr)(DescType desiredType, DescType containerClass, const AEDesc *container, long *result);
  178. typedef pascal OSErr (*OSLDisposeTokenProcPtr)(DescPtr unneededToken);
  179. typedef pascal OSErr (*OSLGetMarkTokenProcPtr)(const AEDesc *dContainerToken, DescType containerClass, DescPtr result);
  180. typedef pascal OSErr (*OSLGetErrDescProcPtr)(DescPtr *appDescPtr);
  181. typedef pascal OSErr (*OSLMarkProcPtr)(const AEDesc *dToken, const AEDesc *markToken, long index);
  182. typedef pascal OSErr (*OSLAdjustMarksProcPtr)(long newStart, long newStop, const AEDesc *markToken);
  183.  
  184. #if GENERATINGCFM
  185. typedef UniversalProcPtr OSLAccessorUPP;
  186. typedef UniversalProcPtr OSLCompareUPP;
  187. typedef UniversalProcPtr OSLCountUPP;
  188. typedef UniversalProcPtr OSLDisposeTokenUPP;
  189. typedef UniversalProcPtr OSLGetMarkTokenUPP;
  190. typedef UniversalProcPtr OSLGetErrDescUPP;
  191. typedef UniversalProcPtr OSLMarkUPP;
  192. typedef UniversalProcPtr OSLAdjustMarksUPP;
  193. #else
  194. typedef OSLAccessorProcPtr OSLAccessorUPP;
  195. typedef OSLCompareProcPtr OSLCompareUPP;
  196. typedef OSLCountProcPtr OSLCountUPP;
  197. typedef OSLDisposeTokenProcPtr OSLDisposeTokenUPP;
  198. typedef OSLGetMarkTokenProcPtr OSLGetMarkTokenUPP;
  199. typedef OSLGetErrDescProcPtr OSLGetErrDescUPP;
  200. typedef OSLMarkProcPtr OSLMarkUPP;
  201. typedef OSLAdjustMarksProcPtr OSLAdjustMarksUPP;
  202. #endif
  203.  
  204. enum {
  205.     uppOSLAccessorProcInfo = kPascalStackBased
  206.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  207.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DescType)))
  208.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AEDesc*)))
  209.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DescType)))
  210.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(DescType)))
  211.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(AEDesc*)))
  212.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DescPtr)))
  213.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(long))),
  214.     uppOSLCompareProcInfo = kPascalStackBased
  215.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  216.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DescType)))
  217.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AEDesc*)))
  218.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AEDesc*)))
  219.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Boolean*))),
  220.     uppOSLCountProcInfo = kPascalStackBased
  221.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  222.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DescType)))
  223.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DescType)))
  224.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AEDesc*)))
  225.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long*))),
  226.     uppOSLDisposeTokenProcInfo = kPascalStackBased
  227.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  228.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DescPtr))),
  229.     uppOSLGetMarkTokenProcInfo = kPascalStackBased
  230.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  231.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AEDesc*)))
  232.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DescType)))
  233.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DescPtr))),
  234.     uppOSLGetErrDescProcInfo = kPascalStackBased
  235.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  236.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DescPtr*))),
  237.     uppOSLMarkProcInfo = kPascalStackBased
  238.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  239.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AEDesc*)))
  240.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AEDesc*)))
  241.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))),
  242.     uppOSLAdjustMarksProcInfo = kPascalStackBased
  243.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  244.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  245.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  246.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AEDesc*)))
  247. };
  248.  
  249. #if GENERATINGCFM
  250. #define NewOSLAccessorProc(userRoutine)        \
  251.         (OSLAccessorUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLAccessorProcInfo, GetCurrentArchitecture())
  252. #define NewOSLCompareProc(userRoutine)        \
  253.         (OSLCompareUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLCompareProcInfo, GetCurrentArchitecture())
  254. #define NewOSLCountProc(userRoutine)        \
  255.         (OSLCountUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLCountProcInfo, GetCurrentArchitecture())
  256. #define NewOSLDisposeTokenProc(userRoutine)        \
  257.         (OSLDisposeTokenUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLDisposeTokenProcInfo, GetCurrentArchitecture())
  258. #define NewOSLGetMarkTokenProc(userRoutine)        \
  259.         (OSLGetMarkTokenUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLGetMarkTokenProcInfo, GetCurrentArchitecture())
  260. #define NewOSLGetErrDescProc(userRoutine)        \
  261.         (OSLGetErrDescUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLGetErrDescProcInfo, GetCurrentArchitecture())
  262. #define NewOSLMarkProc(userRoutine)        \
  263.         (OSLMarkUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLMarkProcInfo, GetCurrentArchitecture())
  264. #define NewOSLAdjustMarksProc(userRoutine)        \
  265.         (OSLAdjustMarksUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSLAdjustMarksProcInfo, GetCurrentArchitecture())
  266. #else
  267. #define NewOSLAccessorProc(userRoutine)        \
  268.         ((OSLAccessorUPP) (userRoutine))
  269. #define NewOSLCompareProc(userRoutine)        \
  270.         ((OSLCompareUPP) (userRoutine))
  271. #define NewOSLCountProc(userRoutine)        \
  272.         ((OSLCountUPP) (userRoutine))
  273. #define NewOSLDisposeTokenProc(userRoutine)        \
  274.         ((OSLDisposeTokenUPP) (userRoutine))
  275. #define NewOSLGetMarkTokenProc(userRoutine)        \
  276.         ((OSLGetMarkTokenUPP) (userRoutine))
  277. #define NewOSLGetErrDescProc(userRoutine)        \
  278.         ((OSLGetErrDescUPP) (userRoutine))
  279. #define NewOSLMarkProc(userRoutine)        \
  280.         ((OSLMarkUPP) (userRoutine))
  281. #define NewOSLAdjustMarksProc(userRoutine)        \
  282.         ((OSLAdjustMarksUPP) (userRoutine))
  283. #endif
  284.  
  285. #if GENERATINGCFM
  286. #define CallOSLAccessorProc(userRoutine, desiredClass, container, containerClass, form, selectionData, value, accessorRefcon)        \
  287.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLAccessorProcInfo, (desiredClass), (container), (containerClass), (form), (selectionData), (value), (accessorRefcon))
  288. #define CallOSLCompareProc(userRoutine, oper, obj1, obj2, result)        \
  289.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLCompareProcInfo, (oper), (obj1), (obj2), (result))
  290. #define CallOSLCountProc(userRoutine, desiredType, containerClass, container, result)        \
  291.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLCountProcInfo, (desiredType), (containerClass), (container), (result))
  292. #define CallOSLDisposeTokenProc(userRoutine, unneededToken)        \
  293.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLDisposeTokenProcInfo, (unneededToken))
  294. #define CallOSLGetMarkTokenProc(userRoutine, dContainerToken, containerClass, result)        \
  295.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLGetMarkTokenProcInfo, (dContainerToken), (containerClass), (result))
  296. #define CallOSLGetErrDescProc(userRoutine, appDescPtr)        \
  297.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLGetErrDescProcInfo, (appDescPtr))
  298. #define CallOSLMarkProc(userRoutine, dToken, markToken, index)        \
  299.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLMarkProcInfo, (dToken), (markToken), (index))
  300. #define CallOSLAdjustMarksProc(userRoutine, newStart, newStop, markToken)        \
  301.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSLAdjustMarksProcInfo, (newStart), (newStop), (markToken))
  302. #else
  303. #define CallOSLAccessorProc(userRoutine, desiredClass, container, containerClass, form, selectionData, value, accessorRefcon)        \
  304.         (*(userRoutine))((desiredClass), (container), (containerClass), (form), (selectionData), (value), (accessorRefcon))
  305. #define CallOSLCompareProc(userRoutine, oper, obj1, obj2, result)        \
  306.         (*(userRoutine))((oper), (obj1), (obj2), (result))
  307. #define CallOSLCountProc(userRoutine, desiredType, containerClass, container, result)        \
  308.         (*(userRoutine))((desiredType), (containerClass), (container), (result))
  309. #define CallOSLDisposeTokenProc(userRoutine, unneededToken)        \
  310.         (*(userRoutine))((unneededToken))
  311. #define CallOSLGetMarkTokenProc(userRoutine, dContainerToken, containerClass, result)        \
  312.         (*(userRoutine))((dContainerToken), (containerClass), (result))
  313. #define CallOSLGetErrDescProc(userRoutine, appDescPtr)        \
  314.         (*(userRoutine))((appDescPtr))
  315. #define CallOSLMarkProc(userRoutine, dToken, markToken, index)        \
  316.         (*(userRoutine))((dToken), (markToken), (index))
  317. #define CallOSLAdjustMarksProc(userRoutine, newStart, newStop, markToken)        \
  318.         (*(userRoutine))((newStart), (newStop), (markToken))
  319. #endif
  320.  
  321. extern pascal OSErr AEObjectInit(void);
  322. /* Not done by inline, but by direct linking into code.  It sets up the pack
  323.   such that further calls can be via inline */
  324. extern pascal OSErr AESetObjectCallbacks(OSLCompareUPP myCompareProc, OSLCountUPP myCountProc, OSLDisposeTokenUPP myDisposeTokenProc, OSLGetMarkTokenUPP myGetMarkTokenProc, OSLMarkUPP myMarkProc, OSLAdjustMarksUPP myAdjustMarksProc, OSLGetErrDescUPP myGetErrDescProcPtr)
  325.  THREEWORDINLINE(0x303C, 0x0E35, 0xA816);
  326. extern pascal OSErr AEResolve(const AEDesc *objectSpecifier, short callbackFlags, DescPtr theToken)
  327.  THREEWORDINLINE(0x303C, 0x0536, 0xA816);
  328. extern pascal OSErr AEInstallObjectAccessor(DescType desiredClass, DescType containerType, OSLAccessorUPP theAccessor, long accessorRefcon, Boolean isSysHandler)
  329.  THREEWORDINLINE(0x303C, 0x0937, 0xA816);
  330. extern pascal OSErr AERemoveObjectAccessor(DescType desiredClass, DescType containerType, OSLAccessorUPP theAccessor, Boolean isSysHandler)
  331.  THREEWORDINLINE(0x303C, 0x0738, 0xA816);
  332. extern pascal OSErr AEGetObjectAccessor(DescType desiredClass, DescType containerType, OSLAccessorUPP *accessor, long *accessorRefcon, Boolean isSysHandler)
  333.  THREEWORDINLINE(0x303C, 0x0939, 0xA816);
  334. extern pascal OSErr AEDisposeToken(DescPtr theToken)
  335.  THREEWORDINLINE(0x303C, 0x023A, 0xA816);
  336. extern pascal OSErr AECallObjectAccessor(DescType desiredClass, const AEDesc *containerToken, DescType containerClass, DescType keyForm, const AEDesc *keyData, DescPtr token)
  337.  THREEWORDINLINE(0x303C, 0x0C3B, 0xA816);
  338.  
  339. #if PRAGMA_IMPORT_SUPPORTED
  340. #pragma import off
  341. #endif
  342.  
  343. #if PRAGMA_ALIGN_SUPPORTED
  344. #pragma options align=reset
  345. #endif
  346.  
  347. #ifdef __cplusplus
  348. }
  349. #endif
  350.  
  351. #endif /* __AEOBJECTS__ */
  352.